package com.smh.a06comprehensiveExercises;

import java.time.LocalDate;
import java.util.Calendar;

public class Test5 {
    public static void main(String[] args) {

        //jdk7
        //
        Calendar calendar =Calendar.getInstance();
        calendar.set(2000, Calendar.MARCH,1);
        calendar.add(Calendar.DAY_OF_MONTH,-1);
        int a =calendar.get(Calendar.DAY_OF_MONTH);
        if (a==29){
            System.out.println("闰");
        }else {
            System.out.println("平");
        }
        System.out.println(a);

        calendar.set(2001,Calendar.JANUARY,1);
        calendar.add(Calendar.DAY_OF_MONTH,-1);
        int day = calendar.get(Calendar.DAY_OF_YEAR);
        if (day==365){
            System.out.println("平");
        }else {
            System.out.println("润");
        }

        //jdk8
        LocalDate localDate = LocalDate.of(2000,3,1);

        LocalDate localDate1 = localDate.minusDays(1);
        if (localDate1.getDayOfMonth()==29){
            System.out.println("run");
        }else {
            System.out.println("ping");
        }

        localDate = LocalDate.of(2001,1,1);
        LocalDate localDate2 = localDate.minusDays(1);
        if (localDate2.getDayOfYear()==365){
            System.out.println("ping");
        }else {
            System.out.println("run");
        }

        //判断闰年和平年
        System.out.println(localDate2.isLeapYear());
        System.out.println(localDate1.isLeapYear());

    }
}
